<?php
	//Should be included everywhere
	require_once('../data.php');
	require_once('model/include_dao.php');
	echo "entering...";
	//Name of the database
	$database_name = 'library';
	//Also should be included everywhere
	ConnectionProperty::$database_path = $database_path;
	ConnectionProperty::$database_name = $database_name;
	
	$doc=DAOFactory::getDocumentDAO()->load(1);
	
	var_dump($doc);
	//$rand = strstr($doc['file'],'.',true);
	//echo $rand;
	//$id = DAOFactory::getDocumentDAO()->insert($doc);
	//echo "ID=".$id;
	//var_dump($doc);
	
	
	/*
	
	var_dump($project);
	
	//Examples of using DAO
	echo "<h2>Get Categories...</h2>";
	
	//$cat = new Category();
	echo "Loading category...<br>";
	$cat=DAOFactory::getCategoriesDAO()->load(1);
	
	var_dump($cat);
	/*
	echo "<br>Inserting new Category...<br>";
	$cat1 = new Category();
	$cat1->setId(1);
	$cat1->setCategory('Category4');
	$n=DAOFactory::getCategoriesDAO()->insert($cat1);
	echo "<br>Inserted: ".$n." row<br>";
	var_dump($cat=DAOFactory::getCategoriesDAO()->load($n));
	echo "<br><br>Loading All Categories...<br>";
	$allCat=DAOFactory::getCategoriesDAO()->queryAll();
	print_r($allCat);
	
	echo "<br>Update category with ID=1";
	$cat2 = new Category();
	$cat2->setId(1);
	$cat2->setCategory('Update Category1');
	$n=DAOFactory::getCategoriesDAO()->update($cat2);
	echo "<br>Updated: ".$n." row<br>";
	
	echo "<br>Createing Category with transaction...<br>";
	$transaction = new Transaction();
	$cat1 = new Category();
	$cat1->setId(1);
	$cat1->setCategory('Category4');
	$n=DAOFactory::getCategoriesDAO()->insert($cat1);
	echo "Inserted: ".$n." row<br>";
	print_r($cat=DAOFactory::getCategoriesDAO()->load($n));
	echo "<br>ROLLBACK<br>";
	$transaction->rollback();
	
	
	echo "<h2>Get Document...</h2>";
	$doc = new Document();
	echo "Loading Document..<br>";
	$doc=DAOFactory::getLibraryDAO()->load(10);
	echo "<br>Document ID: ".$doc->getId();
	echo "<br>UID: ".$doc->getUid();
	echo "<br>Addition Date: ".$doc->getAdditionDate();
	echo "<br>Modification Date: ".$doc->getModifiedDate();
	echo "<br>Added By: "; print_r($doc->getAddedBy());
	echo "<br>Modified By: "; print_r($doc->getModifiedBy());
	echo "<br>Metadata==><br>";
	print_r($doc->getMetadata());
	echo "<br><br>File==><br>";
	print_r($doc->getFile());
	echo "<br><br>Categories==><br>";
	print_r($doc->getCategories());
	echo "<br><br>Notes==><br>";
	print_r($doc->getNotes());
	echo "<br><br>Projects==><br>";
	print_r($doc->getProjects());
	
	*/

?>